<?php 

/** DAO de curso */
class DaoBanco extends DAO {
	
	public function get($id) {
		$select = db_select(Banco::TYPE)
		->fields(Banco::TYPE)
		->condition('id', $id)
		->execute()
		->fetchAll();
		
		$banco = new Banco();
		foreach($select as $row) {			
			$banco->id 					= $row->id;
			$banco->nome 				= $row->nome;
		}
		
		return $banco;
	}
	
	/** Carrega varias instancias do banco */
	public function listar() {
		$select = db_select(Banco::TYPE)
								->fields(Banco::TYPE)
									->execute()
										->fetchAll();
		
		$bancos = array();
		foreach($select as $row) {
			$banco 							= new Banco();
			$banco->id 					= $row->id;
			$banco->nome 				= $row->nome;
					
			array_push($bancos, $banco);
		}
		
		return $bancos;
	}
	
}

